<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>今天星期几？</title>
	</head>
	<body>
		<h2 id="day" align="center"></h2>
		
		<script>
			//从Date 对象返回一周中的某一天(0~6)
			var date=new Date().getDay();
			//
			var h2=document.getElementById('day');
			
			var s="今天星期";
			 
			 switch(date){
			 	case 0:
			 	   s +="天";
			 	   break;
			 	case 1:
			 	   s +="一";
			 	   break;
			 	case 2:
			 	   s +="二";
			 	   break;
			 	case 3:
			 	   s +="三";
			 	   break;
			 	case 4:
			 	   s +="四";
			 	   break;
			 	case 5:
			 	   s +="五";
			 	   break;
			 	case 6:
			 	   s +="六";
			 	   break;
			 	   default:
			 	   break;
			 }
			 //设置元素显示内容
			h2.innerHTML= s ;
		</script>
	</body>
</html>
